<%
  privacy_name = @repository.private? ? t(".public") : t(".private")
  value = @repository.private? ? "public" : "private"
%>

<details class="details-reset details-overlay details-overlay-dark">
  <summary class="btn btn-danger btn-submit" aria-haspopup="dialog"><%= t(".Make privacy", privacy: privacy_name) %></summary>
  <details-dialog class="box d-flex flex-column anim-fade-in fast">
    <div class="box-header mb-2">
      <button class="btn-cancel" type="button" data-close-dialog>
        <%= icon_tag "cancel" %>
      </button>
      <h3 class="box-title"><%= t(".Make this repository privacy", privacy: privacy_name) %></h3>
    </div>

    <div class="box-body overflow-auto">
      <%= form_with(model: @repository, url: user_repository_settings_path(@user, @repository), method: :put) do |form| %>
        <p class="text-gray-light f6 mb-4">
          <% if @repository.private? %>
            <%= t(".Set the repository as public, this repository and all docs will be visible to everyone") %> <%= Setting.host %>.
          <% else %>
            <%= t(".Set the repository as private, all subscribers will be removed") %>
          <% end %>
        </p>

        <%= form.hidden_field :privacy, value: value %>

        <div class="form-group">
          <label class="control-label"><%= t(".Please enter the repository path") %> <strong class="text-red"><%= @repository.slug %></strong> <%= t(".to confirm") %></label>
          <input type="text" confirm-for="#btn-confirm-change-private" confirm-value="<%= @repository.slug %>" autocomplete="off" class="form-control" />
        </div>

        <div class="actions">
          <button type="submit" id="btn-confirm-change-private" disabled class="btn btn-danger btn-block">
            <%= t(".Confirm and submit", privacy: privacy_name) %>
          </button>
        </div>
      <% end %>
    </div>

  </details-dialog>
</details>